package com.srd.phone.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioGroup;

import com.shengrongdai.srd.R;
import com.srd.phone.fragment.RetrievePwdEmailFragment;
import com.srd.phone.fragment.RetrievePwdPhoneFragment;

/**
 * 找回密码，填写验证码
 */
public class RetrievePwdActivity extends BaseActivity {

    private RadioGroup rg_retrieve;
    private LinearLayout ll_phone;
    private LinearLayout ll_email;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_retrieve_pwd);
        initView();
        initData();
    }

    public void initView() {
        tv_common_title.setText("找回密码");
        ll_phone = (LinearLayout) findViewById(R.id.ll_phone);
        ll_email = (LinearLayout) findViewById(R.id.ll_email);
        rg_retrieve = (RadioGroup) findViewById(R.id.rg_retrieve);
    }

    @Override
    public void initData() {
        super.initData();
        replaceFragment(R.id.ll_phone, new RetrievePwdPhoneFragment());
        replaceFragment(R.id.ll_email, new RetrievePwdEmailFragment());
        rg_retrieve.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (R.id.rb_phone == checkedId) {
                    ll_phone.setVisibility(View.VISIBLE);
                    ll_email.setVisibility(View.GONE);
                } else if (checkedId == R.id.rb_email) {
                    ll_phone.setVisibility(View.GONE);
                    ll_email.setVisibility(View.VISIBLE);
                }
            }
        });
        rg_retrieve.check(R.id.rb_phone);
    }
}